<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cls{
            width: 200px;
            height: 200px;
            background-color: skyblue;
        }
    </style>
</head>
<body>
    <div id="app">
        <h1>app</h1>
        <p>msg:{{msg}}</p>
        <book class="cls" id="book01" name="三国演义" price="12" ></book>
    </div>
</body>
</html>
<script src="./js/vue.global.js"></script>
<script>

    let comments = {
        template:`
            <h1>comments组件</h1>
            <div>这本书真好</div>
        `,
        mounted(){
            console.log("comments组件的this.$attrs",this.$attrs);//id和class被深层次的透传到comments组件了
        }
    }

    let Book = {
        props:["name","price"],
        template:`           
            <comments></comments>
        `,
        components:{comments},
        mounted(){
            console.log("Book组件的this.$attrs",this.$attrs);
        }
    }

   

     let app = Vue.createApp({
        data(){
            return {
                msg:"hello" 
            }
        },
        methods:{
            changeFn(str){
                console.log("父组件中获得的子组件的值：",str);
            }
        }
    });

    // book组件是在app上全局注册的。
    app.component("book",Book);
    

    app.mount("#app");
    



</script>